import { useState, useEffect } from 'react';
import { debounce } from 'lodash';
const useMouse = () => {
  const [position, setPosition] = useState({ x: 0, y: 0 });

  useEffect(() => {
    const handleMouseMove = debounce((e: MouseEvent) => {
      setPosition({ x: e.clientX, y: e.clientY });
    }, 100);

    window.addEventListener('mousemove', handleMouseMove);

    return () => {
      window.removeEventListener('mousemove', handleMouseMove);
    };
  }, []);

  return position;
};

export default useMouse;
